package com.kjc.demo.basic.event;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class UserEventListener {
	
	/**
	 * 	事件监听器，监听发布的消息，异步处理
	 * */
	@Async("lazyTraceExecutor")//@Async注解帮我们实现了创建线程池的繁琐，提高了我们的开发效率。
    @EventListener(condition = "#user.name!=null")
    public void handleEvent(UserDto user) throws Exception{
        System.out.println(user.getName());
        System.out.println(user.getSex());
    }
}